<template>
  <tr>
    <td>
      <input v-model="item.checked" type="checkbox" />
    </td>
    <td>{{ item.name }}</td>
    <td>{{ item.price }}</td>
    <td>
      <button @click="minus">-</button>
      {{ item.num }}
      <button @click="add">+</button>
    </td>
    <td>{{ item.price * item.num }}</td>
    <td>
      <button @click="del">删除</button>
    </td>
  </tr>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    item: {
      type: Object,
      default() {
        return {};
      },
    },
    index: {
      type: Number,
      default: 0,
    },
  },
  methods: {
    minus() {
      this.$emit("minus", this.index);
    },
    add() {
      this.$emit("add", this.index);
    },
    del() {
      this.$emit("del", this.index);
    },
  },
};
</script>

<style lang="scss" scoped>
</style>